package edu.hitsz.prop;

import edu.hitsz.aircraft.HeroAircraft;
import edu.hitsz.application.Main;
import edu.hitsz.basic.AbstractFlyingObject;
import edu.hitsz.effect.EffectStrategy;
import edu.hitsz.observer.BombObserver;


/**
 * 所有种类道具的抽象父类：
 * 道具（BULLET, BOMB, BLOOD）
 *
 * @author HMount
 */
public class AbstractProp extends AbstractFlyingObject {
    /** 道具类型  blood:0  bomb:1 bullet:2 */
    protected int type;

    protected EffectStrategy effectStrategy;

    public AbstractProp(int locationX, int locationY, int speedX, int speedY) {
        super(locationX, locationY, speedX, speedY);
    }

    @Override
    public void forward() {
        super.forward();
        // 判定 y 轴向下飞行出界
        if (locationY >= Main.WINDOW_HEIGHT ) {
            vanish();
        }
    }

    @Override
    public int getType() {
        return this.type;
    }
    public  void takeEffect(HeroAircraft heroAircraft){
        effectStrategy.takeEffect(heroAircraft);
    };
    public  void takeEffect(BombObserver bombObserver){
        effectStrategy.takeEffect(bombObserver);
    };
    public  void loseEffect(HeroAircraft heroAircraft){
        effectStrategy.loseEffect(heroAircraft);
    };

}
